<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>日志管理</title>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>
<body class="iframeBody">
<div class="Wrapper">
    <div class="searchArea">
        <!-- 查询表单 -->
        <form id="searchBar">
            <div class="fieldset1 clearFix">
                <div class="fieldBox col_33">
                    <div class="label">所属前端</div>
                    <div class="field">
                        <select name="searchFrontCd" id="searchFrontCd">
                            <c:forEach items="${frontCdList }" var="frontCdTemp">
                                <option value="${frontCdTemp.key }">${frontCdTemp.value }</option>
                            </c:forEach>
                        </select>
                    </div>
                </div>

                <div class="fieldBox col_33">
                    <div class="label">申诉结果</div>
                    <div class="field">
                        <select name="searchResult" id="searchResult">
                            <c:forEach items="${resultList }" var="resultListTemp">
                                <option value="${resultListTemp.key }">${resultListTemp.value }</option>
                            </c:forEach>
                        </select>
                    </div>
                </div>

                <div class="fieldBox col_33">
                    <div class="label">员工工号</div>
                    <div class="field">
                        <input name="searchUsrNm" id="searchUsrNm" type="text" class="ui-textbox" value="">
                    </div>
                </div>

                <div class="fieldBox col_33">
                    <div class="label">员工姓名</div>
                    <div class="field">
                        <input name="searchRlNm" id="searchRlNm" type="text" class="ui-textbox" value="">
                    </div>
                </div>

                <div class="clearFix"></div>
                <div class="btnsBox formBtns notRight">
                    <span id="searchBtn" class="sq-button-round" onclick="searchBtnEvent()">查询</span>
                    <span id="clearBtn" class="sq-button-round" onclick="clearBtnEvent()">清空</span>
                </div>
            </div>
        </form>
    </div>
    <!-- 列表显示块 -->
    <div id="ligergrid" class="sq-grid"></div>
</div>

<script type="text/javascript">
    var grid = null;
    $(function () {
        initForm();//初始化表单
        initGrid();//注意初始化要在initForm之后,因为在初始化grid的时候需要form参数
    });

    //初始化表单
    function initForm() {
        $("#searchBar").ligerForm();
    }

    //初始化列表
    function initGrid() {
        $("#ligergrid").ligerGrid({
            url: '<%=path%>/system/sysusrappeallog/initList.do',
            method: 'post',
            parms: getSearchParams(),
            columns: [
                {display: '前端代码', name: 'sysCdNm', minWidth: 40, align: 'center', enabledSort: true},
                {display: '事业部', name: 'buOrgCdNm', minWidth: 100, align: 'center', enabledSort: true},
                {display: '工号', name: 'usrNm', width: 80, align: 'center', enabledSort: true},
                {display: '姓名', name: 'rlNm', width: 100, align: 'center', enabledSort: true},
                {display: '证件号', name: 'certNo', width: 180, align: 'center', enabledSort: true},
                {display: '手机号', name: 'mp', width: 120, align: 'center', enabledSort: true},
                {
                    display: '申诉状态', name: 'result', width: 70, align: 'center', enabledSort: true,
                    render: function (rowdata, rowindex, value) {
                        var vstr = "未知";
                        if (value == "0") {
                            vstr = "申诉中";
                        } else if (value == "1") {
                            vstr = "申诉成功";
                        } else if (value == "2") {
                            vstr = "申诉失败";
                        }
                        return vstr;
                    }
                },

                {display: '申诉时间', name: 'crtTm', width: 140, align: 'center', render: renderDate, enabledSort: true},
                getGridOperColumnContent()
            ],
            pageSize: 20,
            root: 'rows',
            record: 'total',
            hideLoadButton: false,
            width: '100%',
            selectRowButtonOnly: true,
            height: '100%',
            heightDiff: -2,
            checkbox: false,//列表是否有选择框
            rownumbers: true//列表是否有行号
        });
        grid = liger.get("ligergrid");
        grid.options.isSingleCheck = true;//列表是否为单选
        //查询数据
        // searchBtnEvent(null);
    }

    //查询参数
    function getSearchParams() {
        var form = new liger.get("searchBar");
        var data = form.getData();
        return data;
    }

    //Grid操作列
    function getGridOperColumnContent() {
        var data = {
            display: '操作',
            isSort: false,
            width: 140,
            render: function (rowdata, rowindex, value) {
                var h = '<a class="sq-button-hasicon" href="javascript:toDetailInfo(';
                h += "'" + rowdata.id + "'";
                h += ")\"><i class=\"sqBtnIco_2\"></i>详情</a>";
                if (rowdata.result == '0') {
                    var b = '<a class="sq-button-hasicon" href="javascript:toModifyInfo(';
                    b += "'" + rowdata.id + "'";
                    b += ")\"><i class=\"sqBtnIco_2\"></i>处理</a>";
                    h = h + b;
                }
                return h;
            }
        }
        return data;
    }

    //跳转到新增修改页面
    function toDetailInfo(_id) {
        $.ligerDialog.SQopen({
            cls: 'noBorder_Dialog',
            width: 750,
            height: 500,
            title: '申诉详情',
            url: '<%=path%>/system/sysusrappeallog/toDetailPage.do?id=' + _id,
            // 自定义buttons的时候 不要设置 fixButtons: true
            buttons: [
                {
                    text: "返回", type: 'cancel', cls: 'l-dialog-btn-no',
                    onclick: function (item, Dialog) {
                        //在子页面里绑定 frameElement.dialog.onCancel = function () {}
                        if (Dialog.onCancel) Dialog.onCancel();
                    }
                }
            ]
        });
    }

    //跳转到新增修改页面
    function toModifyInfo(_id) {
        $.ligerDialog.SQopen({
            cls: 'noBorder_Dialog',
            width: 750,
            height: 500,
            title: '申诉详情',
            url: '<%=path%>/system/sysusrappeallog/toModifyPage.do?id=' + _id,
            // 自定义buttons的时候 不要设置 fixButtons: true
            buttons: [
                {
                    text: "确定", type: 'ok', cls: 'l-dialog-btn-ok',
                    onclick: function (item, Dialog) {
                        //在子页面里绑定 frameElement.dialog.onOk = function () {}
                        if (Dialog.onOk) {
                            Dialog.onOk(function (flag) {
                                //调用完成操作
                                if (flag == true) {
                                    searchBtnEvent();
                                    UIUtils.alertSuccess("操作成功!");
                                }
                            });
                        }
                    }
                }, {
                    text: "取消", type: 'cancel', cls: 'l-dialog-btn-no',
                    onclick: function (item, Dialog) {
                        if (Dialog.onCancel) Dialog.onCancel();
                    }
                }
            ]
        });
    }

    //格式化时间
    function renderDate(rowdata, index, value) {
        var dateStr = "";
        if (null != value) {
            var date = new Date(value);
            dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DDHHMMSS);
        }
        return dateStr;
    }

    //查询按钮事件
    function searchBtnEvent() {
        var form = new liger.get("searchBar");
        var data = form.getData();
        for (name in data) {
            grid.setParm(name, data[name]);
        }
        grid.reload();
    }

    //清空按钮事件
    function clearBtnEvent() {
        var form = new liger.get("searchBar");
        form.setData({
            searchFrontCd: "11002",
            searchResult: "0",
            searchUsrNm: " ",
            searchUsrRlNm: " "
        });
    }
</script>
</body>
</html>
